package config

import (
	"github.com/pelletier/go-toml"
	"log"
	"path/filepath"
	"sync"
)

var instance *toml.Tree
var once sync.Once

var (
	Conf = New()
)

func New() *toml.Tree {
	once.Do(func() {
		path, _ := filepath.Abs("config.toml")
		config, err := toml.LoadFile(path)
		if err != nil {
			log.Fatal("config toml error ", err.Error())
		}
		instance = config
	})
	return instance
}
